package com.example.dou2204.ban;

import androidx.lifecycle.MutableLiveData;

import com.example.dou2204.baseMVVM.BaseRepo;
import com.example.dou2204.entity.BannerEntity;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

public class BannerRepo extends BaseRepo {
    public void banner(MutableLiveData<BannerEntity> success,MutableLiveData<String> fail){
        apiServer.banner()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Observer<BannerEntity>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(BannerEntity entity) {
                        success.postValue(entity);
                    }

                    @Override
                    public void onError(Throwable e) {
                        fail.postValue(e.getMessage());
                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }
}
